﻿@model Supplier
@{
    ViewBag.Title = "Index";
}

<h3 style="color:red;">Quản Lý Nhà Cung Cấp</h3><br/>

<div role="tabpanel">

    <!-- Nav tabs -->
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a href="#edit" aria-controls="edit" role="tab" data-toggle="tab">Thêm Nhà Cung Cấp &nbsp;<span class="glyphicon glyphicon-home"></span></a></li>
        <li role="presentation"><a href="#list" aria-controls="list" role="tab" data-toggle="tab">Danh Sách Nhà Cung Cấp &nbsp;<span class="glyphicon glyphicon-th-list"></span></a></li>
    </ul>

    <!-- Tab panes -->
    <div class="tab-content">
        <div role="tabpanel" class="tab-pane active" id="edit">
            <h4>@Html.ValidationSummary()</h4>
            @using (Html.BeginForm("Insert", "Supplier",
    FormMethod.Post, new { enctype = "multipart/form-data" }))
            {
                
               <div class="row">
                   <div class="col-md-4">
                       <div class="form-group">
                           <div>Ký Hiệu</div>
                           @Html.TextBoxFor(s => s.Id, new { @class = "form-control" })
                       </div>
                       <div class="form-group">
                           <div>Tên Nhà Cung Cấp</div>
                           @Html.TextBoxFor(s => s.Name, new { @class = "form-control" })
                       </div>

                       <div class="form-group">
                           <div>Số Điện Thoại</div>
                           @Html.TextBoxFor(s => s.Phone, new { @class = "form-control" })
                       </div>

                       <div class="form-group">
                           <div>Địa Chỉ Mail</div>
                           @Html.TextBoxFor(s => s.Email, new { @class = "form-control" })
                       </div>
                   </div>
                   <div class="col-md-4">
                       <div class="form-group">
                           <div>Logo</div>
                           <img style="width:130px;height:150px;" src="/images/suppliers/@Model.Logo" /><br />
                           <input type="file" name="UpPhoto" />
                           @Html.HiddenFor(s => s.Logo)
                       </div>
                   </div>
               </div>

               

               

                <div class="form-group">
                    <div></div>
                    <div>
                        <button onclick="form.action='/Admin/Supplier/Insert'" class="btn btn-default">Insert</button>
                        @if (!String.IsNullOrEmpty(Model.Id))
                        {
                            <button onclick="form.action='/Admin/Supplier/Update'" class="btn btn-default">Update</button>
                                <a href="/Admin/Supplier/Delete/@Model.Id" onclick="return Xoa();" class="btn btn-default">Delete</a>
                        }
                        <a href="/Admin/Supplier/Index" class="btn btn-default">Reset</a>
                    </div>
                </div>
            }
        </div>
        <div role="tabpanel" class="tab-pane" id="list">
            <br/><br/>
            <table class="table table-hover">
                <tr>
                    <th>Id</th>
                    <th>Ký Hiệu</th>
                    <th>Địa Chỉ Mail</th>
                    <th>Số Điện Thoại</th>
                    <th>Logo</th>
                    <th></th>
                </tr>
                @foreach (var s in ViewBag.Suppliers)
                {
                    <tr>
                        <td>@s.Id</td>
                        <td>@s.Name</td>
                        <td>@s.Email</td>
                        <td>@s.Phone</td>
                        <td> <img style="width:100px;height:50px;" src="~/images/suppliers/@s.Logo"></td>
                        <td>
                            <a href="/Admin/Supplier/Edit/@s.Id"
                               class="btn btn-default">Edit</a>
                            <a href="/Admin/Supplier/Delete/@s.Id" onclick="return Xoa();" class="btn btn-default">Delete</a>
                        </td>
                    </tr>
                }
            </table>
        </div>
    </div>

</div>

@section scripts{


    <script>
    function Xoa() {
        var ok = confirm("Có chắc chắn xóa mẫu tin có mã  không?");
        if (ok == true) {
            window.location.href = "/Admin/Supplier/Delete/@Model.Id";
        } else {
            return false;
        }
    }
    </script>

}



